package com.ins1st.plus.web.admin;

import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @program: ins1st-plus
 * @description: 异常控制层
 * @author: coderSun
 * @create: 2019-09-03 13:29
 **/
@Controller
public class ErrorHandlerController implements ErrorController {

    @RequestMapping(value = "/error")
    public String handleError(HttpServletRequest request) {
        //获取statusCode:401,404,500
        Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
        if (statusCode == 404) {
            return "pages/404.html";
        } else {
            return "pages/500.html";
        }

    }

    @Override
    public String getErrorPath() {
        return "/error";
    }
}
